package com.xmall.product.controller.api;

import com.xmall.annotation.LoginRequiredFalse;
import com.xmall.define.base.Result;
import com.xmall.product.define.dto.spu.SpuResponseDto;
import com.xmall.product.service.ISpuInfoService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 商品
 */
@RestController
@RequestMapping("/service/product/api/spu")
public class ApiSpuInfoController {

    @Resource
    private ISpuInfoService spuInfoService;

    /**
     * 详情
     */
    @LoginRequiredFalse
    @GetMapping("/{id}")
    public Result<SpuResponseDto> info(@PathVariable("id") Long id) throws Exception{
        SpuResponseDto dto = spuInfoService.apiInfo(id);
        return null != dto ? Result.success(dto) : Result.error();
    }
}
